package com.hopu.blb_erp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hopu.blb_erp.entity.PageEntity;
import com.hopu.blb_erp.entity.TVehicle;
import com.hopu.blb_erp.mapper.VehicleMapper;
import com.hopu.blb_erp.service.VehicleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, TVehicle> implements VehicleService {
    @Autowired
    private VehicleMapper vehicleMapper;
    @Override
    public List<TVehicle> findAllVehicle() {
        return vehicleMapper.selectAllVehicle();
    }



    @Override
    public PageEntity<TVehicle> findLogsPages(Integer current, Integer pageSize,String vehicleName,String numberPlate) {
        // 查询角色总数
        Integer count = vehicleMapper.selectVehicleCount(vehicleName,numberPlate);
        // 分页查询订单
        List<TVehicle> vehicles = vehicleMapper.selectVehiclePages((current-1) * pageSize, pageSize,vehicleName,numberPlate);
        // 包装到分页对象
        PageEntity<TVehicle> page = new PageEntity<>();
        page.setCount(count);
        page.setData(vehicles);
        page.setCurrent(current);
        return page;//
    }

}
